package com.example.common.conf.mvc;

import com.example.common.conf.constant.Global;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

import javax.annotation.Resource;

/**
 * @Author 朱兴邦
 * @CreateDate： 2020/7/28 11:00
 * @Version 1.0
 */
@Configuration
public class BeanCenter {

    @Resource
    Global global;

    @Bean
    public static JedisPool getJedisPool(Global global) {
        JedisPoolConfig poolConfig = new JedisPoolConfig();
        poolConfig.setMaxIdle(100);
        poolConfig.setMaxTotal(100);
        poolConfig.setMaxWaitMillis(600 * 1000);
        JedisPool jedisPool = new JedisPool(poolConfig, global.getRedisHost(), global.getRedisPort(),
                600 * 1000, global.getRedisAuth());
        return jedisPool;
    }
}
